package mysql

import (
	"gitignore/gitignorerpc/gitignorerpc"
	"gorm.io/gorm"
)

type Video struct {
	gorm.Model
	UserId        int    `gorm:"type:int(50);comment:用户ID"`
	VideoTitle    string `gorm:"type:varchar(50);comment:视频标题"`
	VideoCateGory string `gorm:"type:varchar(50);comment：视频分类"`
}

func (v *Video) FindVideoByList(db *gorm.DB, list []*gitignorerpc.VideoTopicList) []*gitignorerpc.VideoTopicList {
	db.Model(&Video{}).Select("videos.id as video_id,video_title,video_cate_gory,topic_name,topic_intro,hot_level").
		Joins("LEFT JOIN topics ON videos.user_id =topics.id").Find(&list)

	return list
}

func (v *Video) FindVideoByDel(db *gorm.DB, id int64) error {
	return db.Where("id = ? ", id).Delete(v).Error
}
